package ATM;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class Test {
    public static void main(String[] args) {
        // 创建账户
        Account account1 = new Account("123456", "张三", 1000.0, "1234");
        Account account2 = new Account("789012", "李四", 500.0, "5678");

        // 创建账户列表
        List<Account> accounts = new ArrayList<>();
        accounts.add(account1);
        accounts.add(account2);

        // 创建ATM机
        ATM atm = new ATM(accounts);

        // 测试登录
        Optional<Account> loggedAccount = atm.login("123456", "1234");
        if (loggedAccount.isPresent()) {
            System.out.println("登录成功！");
            Account account = loggedAccount.get();

            // 测试存款
            boolean depositResult = atm.deposit(account, 500.0);
            if (depositResult) {
                System.out.println("存款成功，当前余额: " + account.getBalance());
            } else {
                System.out.println("存款失败");
            }

            // 测试取款
            boolean withdrawResult = atm.withdraw(account, 200.0);
            if (withdrawResult) {
                System.out.println("取款成功，当前余额: " + account.getBalance());
            } else {
                System.out.println("取款失败");
            }
        } else {
            System.out.println("登录失败");
        }
    }
}
